load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
load("//javascript:defs.bzl", "closure_js_deps", "closure_test_suite")

package(default_visibility = ["//visibility:public"])

filegroup(
    name = "atoms",
    srcs = glob([
        "**/*.html",
        "**/*.jpg",
        "**/*.js",
        "**/*.png",
        "**/*.svg",
    ]),
    visibility = [
        "//dotnet/test:__subpackages__",
        "//java/test/org/openqa/selenium/environment:__pkg__",
        "//javascript/selenium-webdriver:__pkg__",
    ],
)

closure_js_library(
    name = "action",
    srcs = ["action.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = [
        "//javascript/atoms/fragments:__pkg__",
        "//javascript/selenium-atoms:__pkg__",
        "//javascript/webdriver/atoms:__pkg__",
        "//javascript/webdriver/atoms/inject:__pkg__",
    ],
    deps = [
        ":bot",
        ":devices",
        ":dom",
        ":errors",
        ":events",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
        "@io_bazel_rules_closure//closure/library/math:coordinate",
        "@io_bazel_rules_closure//closure/library/math:vec2",
        "@io_bazel_rules_closure//closure/library/style",
    ],
)

closure_js_library(
    name = "bot",
    srcs = ["bot.js"],
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
)

closure_js_library(
    name = "color",
    srcs = ["color.js"],
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/color:names",
    ],
)

closure_js_library(
    name = "devices",
    srcs = [
        "device.js",
        "keyboard.js",
        "mouse.js",
        "touchscreen.js",
    ],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_MISSING_CONST_PROPERTY",
        "JSC_NULLABLE_RETURN_WITH_NAME",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":dom",
        ":errors",
        ":events",
        ":locators",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:selection",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
        "@io_bazel_rules_closure//closure/library/math:coordinate",
        "@io_bazel_rules_closure//closure/library/structs:map",
        "@io_bazel_rules_closure//closure/library/structs:set",
        "@io_bazel_rules_closure//closure/library/useragent",
        "@io_bazel_rules_closure//closure/library/useragent:product",
    ],
)

closure_js_library(
    name = "domcore",
    srcs = ["domcore.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":errors",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:nodetype",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
    ],
)

closure_js_library(
    name = "dom",
    srcs = ["dom.js"],
    suppress = [
        "JSC_DEPRECATED_PROP",
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":color",
        ":css",
        ":domcore",
        ":json",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:nodetype",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
        "@io_bazel_rules_closure//closure/library/math",
        "@io_bazel_rules_closure//closure/library/math:coordinate",
        "@io_bazel_rules_closure//closure/library/math:rect",
        "@io_bazel_rules_closure//closure/library/string",
        "@io_bazel_rules_closure//closure/library/style",
        "@io_bazel_rules_closure//closure/library/useragent",
    ],
)

closure_js_library(
    name = "errors",
    srcs = [
        "error.js",
        "response.js",
    ],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_MISSING_CONST_PROPERTY",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
)

closure_js_library(
    name = "events",
    srcs = ["events.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_MISSING_CONST_PROPERTY",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":dom",
        ":errors",
        ":json",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/events:browserevent",
        "@io_bazel_rules_closure//closure/library/style",
        "@io_bazel_rules_closure//closure/library/useragent",
        "@io_bazel_rules_closure//closure/library/useragent:product",
    ],
)

closure_js_library(
    name = "frame",
    srcs = ["frame.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_NULLABLE_RETURN_WITH_NAME",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = [
        "//javascript/webdriver/atoms/inject:__pkg__",
    ],
    deps = [
        ":bot",
        ":dom",
        ":errors",
        ":locators",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:tagname",
    ],
)

closure_js_library(
    name = "html5",
    srcs = glob(["html5/*.js"]),
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_NULLABLE_RETURN_WITH_NAME",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":errors",
        ":json",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/useragent:all_js",
    ],
)

closure_js_library(
    name = "inject",
    srcs = ["inject.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    visibility = [
        "//javascript/atoms/fragments:__pkg__",
        "//javascript/selenium-atoms:__pkg__",
        "//javascript/webdriver/atoms/inject:__pkg__",
    ],
    deps = [
        ":bot",
        ":errors",
        ":json",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom:nodetype",
        "@io_bazel_rules_closure//closure/library/object",
        "@io_bazel_rules_closure//closure/library/useragent",
    ],
)

closure_js_library(
    name = "json",
    srcs = ["json.js"],
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":useragent",
        "@io_bazel_rules_closure//closure/library/json",
        "@io_bazel_rules_closure//closure/library/useragent",
    ],
)

closure_js_library(
    name = "locators",
    srcs = glob(
        ["locators/*.js"],
        exclude = ["locators/css.js"],
    ),
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_LATE_PROVIDE_ERROR",
        "JSC_NULLABLE_RETURN_WITH_NAME",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":css",
        ":dom",
        ":errors",
        ":json",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/array",
        "@io_bazel_rules_closure//closure/library/dom",
        "@io_bazel_rules_closure//closure/library/dom:nodetype",
        "@io_bazel_rules_closure//closure/library/math:rect",
        "@io_bazel_rules_closure//closure/library/string",
        "@io_bazel_rules_closure//closure/library/useragent",
        "@io_bazel_rules_closure//closure/library/useragent:product",
    ],
)

closure_js_library(
    name = "useragent",
    srcs = ["userAgent.js"],
    suppress = [
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        "@io_bazel_rules_closure//closure/library/string",
        "@io_bazel_rules_closure//closure/library/useragent",
        "@io_bazel_rules_closure//closure/library/useragent:product",
        "@io_bazel_rules_closure//closure/library/useragent:product_isversion",
    ],
)

closure_js_library(
    name = "window",
    srcs = [
        "frame.js",
        "window.js",
    ],
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":errors",
        ":events",
        ":json",
        ":locators",
    ],
)

closure_js_library(
    name = "css",
    srcs = ["locators/css.js"],
    suppress = [
        "JSC_IMPLICITLY_NULLABLE_JSDOC",
        "JSC_STRICT_INEXISTENT_PROPERTY",
        "JSC_UNKNOWN_EXPR_TYPE",
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":bot",
        ":errors",
        ":useragent",
        "@io_bazel_rules_closure//closure/library/dom:nodetype",
        "@io_bazel_rules_closure//closure/library/string",
        "@io_bazel_rules_closure//closure/library/useragent",
    ],
)

closure_js_library(
    name = "test_util",
    testonly = 1,
    srcs = ["test/test_util.js"],
    suppress = [
        "JSC_USE_OF_GOOG_PROVIDE",
    ],
    deps = [
        ":useragent",
    ],
)

closure_js_deps(
    name = "deps",
    testonly = True,
    visibility = [
        "//:__pkg__",
        "//java/test/org/openqa/selenium/environment:__pkg__",
        "//javascript:__pkg__",
        "//javascript/webdriver:__pkg__",
    ],
    deps = [
        ":action",
        ":bot",
        ":color",
        ":css",
        ":devices",
        ":dom",
        ":domcore",
        ":errors",
        ":events",
        ":html5",
        ":inject",
        ":json",
        ":locators",
        ":test_util",
        ":useragent",
        ":window",
    ],
)

closure_test_suite(
    name = "test",
    data = [
        ":atoms",
        ":deps",
    ],
)
